<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/jsp/common.jsp"%>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>展示岗位和角色</title>
	
	<link href="${pageContext.request.contextPath}/resource/css/def/bootstrap/css/bootstrap-upf.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/resource/css/def/ztree/metro.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath }/resource/css/def/frm/sys/sysOrgAndRoleShow.css" rel="stylesheet"/>
	
	<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery/plugin/jquery.ztree.all-3.5.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery/plugin/My97DatePicker/WdatePicker.js"></script>
	<script src="${pageContext.request.contextPath}/resource/js/jquery/plugin/handlebars-v3.0.1.js"></script>
	<script src="${pageContext.request.contextPath}/resource/js/jquery/plugin/datatables/js/jquery.dataTables.js"></script>
	
	<style type="text/css">
		#orgMessage div label{text-align:right;padding-right:0px;padding-top:5px;margin-bottom:0px;}
		#orgMessage div div{padding-left:0px;margin-bottom:15px;}
		#orgMessage div div input{width:185px;}
		select{width:185px;height:25px;}
		#showOrgById div label{text-align:right;padding-right:0px;padding-top:5px;margin-bottom:0px;}
		#showOrgById div div{padding-left:0px;margin-bottom:5px;padding-top:5px;}
		#addRole div label{text-align:right;padding-top:10px;padding-right:0px;}
		#addRole div div{padding-left:0px;padding-top:5px;}
		#sBtn{margin-top:10px;}
		#updateOrgBorder div label{text-align:right;padding-right:0px;padding-top:5px;margin-bottom:0px;}
		#updateOrgBorder div div{padding-left:0px;margin-bottom:15px;}
		#updateOrgBorder div div input{width:185px;}
	</style>
	<script type="text/javascript">
		/* var zNodes = ${treeArray}; */
		/* var staffOrgTreeArrayNodes = ${staffOrgTreeArray}; */
		var map = ${map};
		var nameOfStaff= "${nameOfStaff}";
	</script>
	<script type="text/javascript">
		var hadPermission = {'update':false,'add':false};
		/* 修改角色 */
		<shiro:hasPermission name="sys:staff:update">
			hadPermission.update =true;
		</shiro:hasPermission>
		/* 添加角色 */
		<shiro:hasPermission name="sys:staff:update">
			hadPermission.add = true;
		</shiro:hasPermission>
	</script>
	</head>
<body>
		<div class="row">
			<div class="headerDiv">${nameOfStaff}的岗位及对应的角色信息</div>
		</div>
		<div class="row">
			<div class="col-md-3">
						<!-- <div class="currentPerson">的岗位及角色信息</div> -->
						<shiro:hasPermission name="sys:staff:update">
						<button class="btn orgbtn btn-success" onclick="showTree();" style="margin-top:0px;">添加岗位</button>
						</shiro:hasPermission>
						<c:choose>
							<c:when test="${not empty list }">
								<c:forEach items="${list }" var="syo">
									<button class="btn orgbtn btn-info" onclick="showStaffOrgM('${syo.STAFF_ORG_ID}','${syo.NAME }')">${syo.NAME }</button>
								</c:forEach>
							</c:when>
						</c:choose>
				<!-- 左边岗位div -->
			</div>

		<div class="col-md-9">
			<!-- Tree -->
			<div class="TreeDiv HdClass" id="TreeDiv">
				<div class="upfpanel-box" style="margin:0px;">
					<div class="upfpanel-header">
						<h5 class="upfpanel-title"><font style="color:red;">*&nbsp;&nbsp;点击选择岗位</font></h5>
						<div class="upfpanel-toolbar">
							<div class="upfpanel-menu">
	
								<a href="#" title="全部展开" onclick="expandAll();"> <span
									class="glyphicon glyphicon-plus" aria-hidden="true"></span>
								</a> <a href="#" title="全部折叠" onclick="collapseAll();"> <span
									class="glyphicon glyphicon-minus" aria-hidden="true"></span>
								</a> <a href="#" title="刷新" onclick="refreshTree();"> <span
									class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
								</a>
							</div>
						</div>
					</div>
					<!-- end of upfpanel-header -->
	
					<div class="upfpanel-body" id="ztreeDiv" style="overflow:auto;">
						<ul id="tree" class="ztree"></ul>
							<!-- 组织机构树 -->
					</div>
				</div>
			</div><!-- Tree end -->
			
			<!-- 添加岗位//////////////////////////////////////////// -->	
			<div class="orgMessageBorder HdClass" id="orgMessageBorder">
				<form action="addStaffOrg.action" id="orgForm" method="post">
					<div class="orgMessage" id="orgMessage">
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="orgName">岗位名称：</label>
								<div class="col-sm-9">
									<input type="text" id="orgName" name="orgName" readonly="readonly"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="orgType">岗位类型：</label>
								<div class="col-sm-9">
									<select class="selectClass" id="orgType" name="orgType" data-placeholder="选择岗位类型">
										<option value="F">主岗</option>
										<option value="T">兼职</option>
										<option value="J">借调</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="hireDate">入职日期：</label>
								<div class="col-sm-9">
									<input type="text" onfocus="WdatePicker()" class="Wdate" id="hireDate" name="hireDate"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="effectStartDate">生效日期：</label>
								<div class="col-sm-9">
									<input type="text" onfocus="WdatePicker()" class="Wdate" id="effectStartDate" name="effectStartDate"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="effectEndDate">结束日期：</label>
								<div class="col-sm-9">
									<input type="text" onfocus="WdatePicker()" class="Wdate" id="effectEndDate" name="effectEndDate"/>
								</div>
							</div>
							<!-- 'M 本人、S 指定人 ，O 本组织，D 本组织及其下级组织，C 下级组织，R 指定组织，T 指定组织及其下级，H 指定组织下级，E，自定义。' -->
							<!-- <div class="form-group">
								<label class="col-sm-3 control-label"
								for="dataPermissionType">数据权限类型：</label>
								<div class="col-sm-9">
									<select class='selectClass' id="dataPermissionType" name="dataPermissionType" onchange="staffOrgRoleSet(this.value);" data-placeholder="数据权限类型">
										<option value="M" selected>本人</option>
										<option value="S">指定人</option>
										<option value="O">本组织</option>
										<option value="D">本组织及其下组织</option>
										<option value="C">下级组织</option>
										<option value="R">指定组织</option>
										<option value="T">指定组织及其下级</option>
										<option value="H">指定组织下级</option>
										 liuym 2016-08-31
										<option value="E">自定义</option>
										
									</select>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<button type="button" id="getTreeSet100" style="display:none;" class="btn btn-primary" onclick="getTreeSet();">查看</button>
								</div>
							</div> -->
							
							<input type="hidden" id="staffId" name="staffId" value="${id }"/><!-- 新增人员的id -->
							<input type="hidden" id="orgId" name="orgId"/>
							<input type="hidden" id="addOrgName" name="addOrgName" value="${nameOfStaff }"/><!-- 新增人员名字 -->
							<input type="hidden" id="treeOrgId" name="treeOrgId"/>
							<input type="hidden" id="treeStaffOrgId" name="treeStaffOrgId"/>
						
					</div><!-- 填写岗位信息 -->
					
					<div class="rightBtnClass">
						<a class="btn btn-success HdClass" id="sBtn" onclick="subminOrgMessage();">提交信息</a>
					</div>
					<input type="reset" name="reset" class="HdClass"/>
					<div style="clear:both;"></div>
				</form>
			</div>
			<!-- 添加岗位div结束////////////////////////////////////////////结束 -->
			
			<!-- 展示岗位div -->
			<div id="showOrgByIdBorder" class="showOrgByIdBorderClass HdClass">
				
				<div id="showOrgByIdR" class="showOrgByIdRClass">
					<shiro:hasPermission name="sys:staff:update">
						<button class="btn btn-info" onclick="updateThisOrg();">修改此岗位</button>
					</shiro:hasPermission>
					<shiro:hasPermission name="sys:staff:update">
						<button class="btn btn-warning" id="deleteOrgBtn" onclick="deleteOrgBtn();">删除岗位</button>
					</shiro:hasPermission>
				</div>
				
				<div id="showOrgById" class="showOrgByIdClass">
					<input type="hidden" name="orgTypeNow" id="orgTypeNow">
					<div class="row">
						<div class="col-md-6">
							<label class="col-sm-4 control-label"
							for="orgName2">岗位名称：</label>
							<div class="col-sm-8" id="orgName2"></div>
						</div>
						
						<div class="col-md-6">
							<label class="col-sm-3 control-label"
							for="orgType2">岗位类型：</label>
							<div class="col-sm-9" id="orgType2"></div>
						</div>
					</div>
					
					<div class="row">
						<div class="col-md-6">
							<label class="col-sm-4 control-label"
							for="status2">在职状态：</label>
							<div class="col-sm-8" id="status2"></div>
						</div>
						<div class="col-md-6">
							<label class="col-sm-3 control-label"
							for="hireDate2">入职日期：</label>
							<div class="col-sm-9" id="hireDate2"></div>
						</div>
					</div>
					
					<div class="row">
						<div class="col-md-6">
							<label class="col-sm-4 control-label"
							for="effectStartDate2">生效日期：</label>
							<div class="col-sm-8" id="effectStartDate2"></div>
						</div>
						<div class="col-md-6">
							<label class="col-sm-3 control-label"
							for="effectEndDate2">结束日期：</label>
							<div class="col-sm-9" id="effectEndDate2"></div>
						</div>
					</div>
					
					<div class="row" style="display:none">
						<div class="col-md-6">
							<label class="col-sm-4 control-label"
							for="dataPermissionType2">数据权限类型：</label>
							<div class="col-sm-8" id="dataPermissionType2"></div>
						</div>
					</div>
					
				</div>
				
			</div>
			
			<!-- 对应岗位    添加/修改    角色、、、、、、、、、、已废除、、、、、、、、、 -->
			<div id="addRole" class="addRoleClass HdClass">
			</div>
			<!-- 对应岗位   添加/修改   角色结束、、、、、、、、、已废除、、、、、、、、、、、 -->
			
			<!-- 添加/修改    角色按钮 -->
			<div id="addRoleShow" class="addRoleClass HdClass">
				
			</div>
			<!-- 添加/修改   角色按钮结束 -->
			
						
			<!-- 修改岗位、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、开始 -->
			<div id="updateOrgBorder" class="orgMessageBorder HdClass">
				<form action="updateSSOrgById.action" id="updateOrgForm" method="post">
					
					<div class="orgMessage" id="updateOrgMessage">
						
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="orgName3">岗位名称：</label>
								<div class="col-sm-9">
									<input type="text" id="orgName3" name="orgName3" readonly="readonly"/><font color="red">&nbsp;&nbsp;岗位名称在此不能修改</font>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="orgType3">岗位类型：</label>
								<div class="col-sm-9">
									<select class="selectClass" id="orgType3" name="orgType3" 
										data-placeholder="选择岗位类型">
										<option value="F">主岗</option>
										<option value="T">兼职</option>
										<option value="J">借调</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="status3">是否有效：</label>
								<div class="col-sm-9">
									<select class="selectClass" id="status3" name="status3">
										<option value="1">有效</option>
										<option value="2">无效</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="hireDate3">入职日期：</label>
								<div class="col-sm-9">
									<input type="text" onfocus="WdatePicker()" class="Wdate" id="hireDate3" name="hireDate3"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="effectStartDate3">生效日期：</label>
								<div class="col-sm-9">
									<input type="text" onfocus="WdatePicker()" class="Wdate" id="effectStartDate3" name="effectStartDate3"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label"
								for="effectEndDate3">结束日期：</label>
								<div class="col-sm-9">
									<input type="text" onfocus="WdatePicker()" class="Wdate" id="effectEndDate3" name="effectEndDate3"/>
								</div>
							</div>
							<!-- 'M 本人、S 指定人 ，O 本组织，D 本组织及其下级组织，C 下级组织，R 指定组织，T 指定组织及其下级，H 指定组织下级，E，自定义。' -->
							<div class="form-group" style="display:none">
								<label class="col-sm-3 control-label"
								for="dataPermissionType3">数据权限类型：</label>
								<div class="col-sm-9">
									<select class='selectClass' id="dataPermissionType3" name="dataPermissionType3" onclick="updateDataPermissionType(this.value);" data-placeholder="数据权限类型">
										<option value="M" selected>本人</option>
										<option value="S">指定人</option>
										<option value="O">本组织</option>
										<option value="D">本组织及其下组织</option>
										<option value="C">下级组织</option>
										<option value="R">指定组织</option>
										<option value="T">指定组织及其下级</option>
										<option value="H">指定组织下级</option>
										<!--  liuym 2016-08-31
										<option value="E">自定义</option>
										-->
									</select>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<button type="button" id="getUpdateTreeSet" style="display:none;" class="btn btn-primary" onclick="getUpdateTreeSet99();">查看</button>
								</div>
							</div>
							
							<input type="hidden" id="staffOrgId2" name="staffOrgId2"/><!-- sys_staff_org表的id -->
							<input type="hidden" id="staffIdToUpdate" name="staffIdToUpdate"/><!-- sys_staff_org表的staffId -->
							<input type="hidden" id="nameOfStaff" name="nameOfStaff" value="${nameOfStaff }"/><!-- 当前人员名字 -->
							<input type="hidden" id="orgId2" name="orgId2"/><!-- sys_staff_org表的org_id -->
							<input type="hidden" id="treeOrgIdUpdate" name="treeOrgIdUpdate"/>
							<input type="hidden" id="treeStaffOrgIdUpdate" name="treeStaffOrgIdUpdate"/>
						
					</div><!-- 修改岗位信息 -->
					
					<div class="rightBtnClass">
						<a class="btn btn-success" id="sBtn" onclick="comfirmUpdate();">确认修改</a>
					</div>
					<div style="clear:both;"></div>
					<input type="reset" name="reset2" class="HdClass"/>
				</form>
			</div>
			<!-- 修改岗位、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、结束 -->
			
			<div class="alertMessage HdClass" id="alertMessage">
				无主岗信息，请添加主岗，或者将无效主岗改为有效，或者修改兼职岗位为主岗。
			</div>
		</div><!-- 右边组织和角色详细信息div -->
		</div>
	
	
	 <!-- 数据权限设置,选择岗位 -->
	<button style="display:none" id="showUser" data-toggle="modal" data-target="#roleModal" >指定人</button>
	<div class="modal fade" id="roleModal" tabindex="-1" role="dialog" aria-labelledby="roleModalLabel" style="display:none;">
		<div class="modal-dialog" role="document" >
		    <div class="modal-content" style="width:550px;height:400px">
		       <div class="modal-header">
					<button type="button" class="btn btn-info" onclick="getStaffOrgTreeValue();" data-dismiss="modal">确定</button>
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		       </div>
		      	<div class="modal-body">
		      		<div class="upfpanel-box" style="margin:0px;width:460px">
						<div class="upfpanel-header" >
							<div class="upfpanel-toolbar">
								<div class="upfpanel-menu">
		
									<a href="#" title="全部展开" onclick="expandAll();"> <span
										class="glyphicon glyphicon-plus" aria-hidden="true"></span>
									</a> <a href="#" title="全部折叠" onclick="collapseAll();"> <span
										class="glyphicon glyphicon-minus" aria-hidden="true"></span>
									</a> <a href="#" title="刷新" onclick="refreshTreeStaffOrg();"> <span
										class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
									</a>
								</div>
							</div>
						</div>
						<!-- end of upfpanel-header -->
		
						<div class="upfpanel-body" id="ztreeDiv99" style="overflow:auto;height:280px">
							<ul id="stafforgtree" class="ztree"></ul>
						</div>
					</div>
			    </div>
			</div>
		</div>
	</div>
	
	
	 <!-- 数据权限设置，选择组织 -->
	<button type="button" style="display:none" id="showOrgTree" data-toggle="modal" data-target="#orgTreeModal" >指定组织</button>
	<div class="modal fade" id="orgTreeModal" tabindex="-1" role="dialog" aria-labelledby="roleModalLabel" aria-hidden="true">
		<div class="modal-dialog" role="document" >
		    <div class="modal-content" style="width: 480px">
		       <div class="modal-header">
					<button type="button" class="btn btn-info" data-dismiss="modal" onclick="getTreeValue();">确定</button>
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		       </div>
		       <div class="modal-body">
					<div class="upfpanel-box" style="margin:0px;width:460px">
						<div class="upfpanel-header" >
							<div class="upfpanel-toolbar">
								<div class="upfpanel-menu">
		
									<a href="#" title="全部展开" onclick="expandAll();"> <span
										class="glyphicon glyphicon-plus" aria-hidden="true"></span>
									</a> <a href="#" title="全部折叠" onclick="collapseAll();"> <span
										class="glyphicon glyphicon-minus" aria-hidden="true"></span>
									</a> <a href="#" title="刷新" onclick="refreshTreeOrg();"> <span
										class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
									</a>
								</div>
							</div>
						</div>
						<!-- end of upfpanel-header -->
		
						<div class="upfpanel-body" id="ztreeDiv100" style="overflow:auto;height:280px">
							<ul id="orgtree" class="ztree"></ul>
								<!-- 组织机构树 -->
						</div>
					</div>
		       </div>

			</div>
		</div>
	</div>
</body>
	<script type="text/javascript" src="${pageContext.request.contextPath }/resource/js/frm/sys/sysOrgAndRoleShow.js"></script>
</html>